package org.wadael.waverobotfrmwrk.advanced.example.workers;

import org.wadael.waverobotfrmwrk.advanced.Command;
import org.wadael.waverobotfrmwrk.advanced.RobotWorker;
import org.wadael.waverobotfrmwrk.utils.BlipUtils;

import com.google.wave.api.Blip;
import com.google.wave.api.event.Event;
import com.google.wave.api.impl.EventMessageBundle;

public class LengthWorker implements RobotWorker {
	@Override
	public String getInstruction() {
		return "len";
	}

	@Override
	public String getDescription() {
		return "Displays the length of the blip ";
	}

	@Override
	public boolean doWork(EventMessageBundle bun, Blip bli, Event eve,String params) 
	{	
		// BlipUtils.appendNewBlipWithContent(eve, "length : " + BlipUtils.getEventBlipText(eve).length() + " characters");
		return true;
	}
	
	@Override
	public boolean areCommandsToClean() {
		return false;
	}
	
	@Override
	public String getReplacingValue(Command c, EventMessageBundle bundle, Blip blip,  Event event) {
		return "" + (BlipUtils.getEventBlipText(event).length() - ( 3+ c.getAcronym().length() + c.getInstruction().length())) ;
	}
}
